﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AdminWeb.Views
{
    static public class ViewHelper
    {
        static List<string> environment = new List<string>(){"production", "development", "test"};
        static List<string> stopOperation = new List<string>() { "no operation", "start" };
        static List<string> startOperation = new List<string>() { "no operation", "stop", "re start" };

        public static IEnumerable<SelectListItem> GetEnvironment(string env = "production")
        {
            var select = (IEnumerable<SelectListItem>) new SelectList(environment).ToList();
            foreach (var i in select)
            {
                if (i.Text == env)
                {
                    i.Selected = true;
                    break;
                }
            }
            return select;
        }

        public static IEnumerable<SelectListItem> GetOperation(string status = "runnuing")
        {
            IEnumerable<SelectListItem> operations;
            if (status == "running")
                operations = (IEnumerable<SelectListItem>) new SelectList(startOperation).ToList();
            else
                operations = (IEnumerable<SelectListItem>)new SelectList(stopOperation).ToList();
            return operations;
        }
    }
}